<template>
  <div>
  <a-card :bordered="false">
    <detail-list title="财务参数:" style="">
      <detail-list-item term="终端地址">{{ finance.appId }} </detail-list-item>
      <detail-list-item term="私钥">{{finance.privateKeyPath }}</detail-list-item>
    </detail-list>
    <div style="height:32px"></div>
    <a-divider style="margin-bottom: 32px"/>
     <a-button  size="large" type="" @click="handleDetails()" style="float : right">编辑</a-button>
     <systemParameter-details ref="details"></systemParameter-details>
  </a-card>
  <div style="margin-bottom: 32px" ></div>
  <a-card :bordered="false">
    <detail-list title="消息参数:">
      <detail-list-item term="访问密钥地址">{{information.accessKeyId  }} </detail-list-item>
      <detail-list-item term="访问密钥">{{ information.accessSecret}}</detail-list-item>
    </detail-list>
    <div style="height:32px"></div>
    <a-divider style="margin-bottom: 32px"/>
    <a-button  size="large" type="" @click="handleInformation()" style="float : right">编辑</a-button>
     <systemInformation-details ref="information" ></systemInformation-details>
  </a-card>
  <div style="margin-bottom: 32px" ></div>
  <a-card :bordered="false">
    <detail-list title="系统版本:">
      <detail-list-item term="安卓版本">{{systemVersion.androidVersion  }} </detail-list-item>
      <detail-list-item term="IOS版本">{{systemVersion.iosVersion}}</detail-list-item>
      <!-- <detail-list-item term="创建时间">{{systemVersion.createTime }}</detail-list-item> -->
    </detail-list>
    <div style="height:32px"></div>
    <a-divider style="margin-bottom: 32px"/>
     <a-button  size="large" type="" @click="handleVersion()" style="float : right">编辑</a-button>
     <systemVersion-details ref="version"></systemVersion-details>
  </a-card>
  </div>
</template>
<script>
import FooterToolBar from '@/components/tools/FooterToolBar'
import DetailList from '@/components/tools/DetailList'
import PageLayout from '@/components/page/PageLayout'
import { log } from 'util'
import ABadge from "ant-design-vue/es/badge/Badge"
import STable from '@/components/table/'
import { filterObj } from '@/utils/util'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { httpAction, getAction } from '@/api/manage'
import systemParameterDetails from './modules/SystemParameterDetails'
import systemInformationDetails from './modules/SystemInformationDetails'
import systemVersionDetails from './modules/SystemVersionDetails'
const DetailListItem = DetailList.Item
export default {
  name: 'SystemParameterForm',
  components: {
    'systemParameter-details': systemParameterDetails,
    'systemInformation-details': systemInformationDetails,
    'systemVersion-details': systemVersionDetails,
    FooterToolBar,
     PageLayout,
      ABadge,
      DetailList,
      DetailListItem,
      STable
  },
  data() {
    return {
      description: '高级表单常见于一次性输入和提交大批量数据的场景。',
      loading: false,
      data: {},
      systemVersion: {},
      finance:{},
      information:{},
      confirmLoading: false,
      visible: false,
      title: '详情',
      validatorRules: {
        //修改
        name: {
          rules: [
            //rules是验证规则，
            {
              required: true, //是否为必填，否则将会出现提示信息
              message: '请输入团名称' //当输入框为空时，呈现出的提示信息
            },
            {
              validator: this.checkName //自定义的校验函数
            }
          ]
        }
        //修改
      },
      url:{
        getAppVersion:'/sys/params/getAppVersion',
        getFinancialParameters:'/sys/params/getFinancialParameters',
        getMessageParams:'/sys/params/getMessageParams'
      }
    }
  },
   created(){
      this.getAppVersion();
      this.getFinancialParameters();
      this.getMessageParams();
    },
    mounted(){
    },
    activated(){
      this.getAppVersion();
      this.getFinancialParameters();
      this.getMessageParams();
    },
  methods: {
    handleDetails() {
      this.$refs.details.show()
    },
    handleInformation(){
      this.$refs.information.show()
    },
    handleVersion(){
      this.$refs.version.show()
    },
    getAppVersion(){
     this.$nextTick(() => {
        getAction(this.url.getAppVersion).then(res => {
          if (res.success) {
            this.systemVersion = res.result
          }
          if (res.code === 510) {
            this.$message.warning(res.message)
          }
        })
      })
    },
    getFinancialParameters(){
     this.$nextTick(() => {
        getAction(this.url.getFinancialParameters).then(res => {
          if (res.success) {
            this.finance=res.result
          }
          if (res.code === 510) {
            this.$message.warning(res.message)
          }
        })
      })
    },
    getMessageParams(){
     this.$nextTick(() => {
        getAction(this.url.getMessageParams).then(res => {
          if (res.success) {
            this.information=res.result
          }
          if (res.code === 510) {
            this.$message.warning(res.message)
          }
        })
      })
    },
    handleSubmit(e) {
      e.preventDefault()
    },
    close() {
      this.$router.replace({path:'/promotion'})
    },
    // 最终全页面提交
    validate() {
      const that = this
      this.loading = true
      let enableSubmit1 = false,
        enableSubmit2 = false
      this.$refs.baseInfo.form.validateFields((err, values) => {
        if (!err) {
          enableSubmit1 = true
        }
      })
      this.$refs.goodsInfo.form.validateFields((err, values) => {
        if (!err) {
          enableSubmit2 = true
        }
      })
      if (enableSubmit1 && enableSubmit2) {
        this.data = {
          ...this.$refs.baseInfo.form.getFieldsValue().couponTemplate,
          ...this.$refs.goodsInfo.form.getFieldsValue().couponTemplate
        }
        this.data.rangeValues = this.data.rangeValues.join()
        this.data.priceAvailable = this.data.priceAvailable * 100
        this.data.discountPriceLimit = this.data.discountPriceLimit * 100

        this.data.priceOff = this.data.priceOff * 100
      } else {
        that.loading = false
      }
    },
     handleOk() {
      this.close()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style lang="scss" scoped>
.ant-col-md-8{
  width: 100%;
}
.card {
  margin-bottom: 24px;
}
</style>
